import java.util.Scanner;

class QuadraticEquationSolver
{
    private double a, b, c;
    public QuadraticEquationSolver(double a, double b, double c)
    {
        this.a = a;
        this.b = b;
        this.c = c;
    }
    public void solve()
    {
        if (a == 0)
        {
            if (b == 0)
            {
                if (c == 0)
                {
                    System.out.println("方程有无穷多解。");
                }
                else {System.out.println("方程无解。");}
            }
            else {System.out.println("线性方程的解为：x = " + (-c / b));}
        }
        else
        {
            double discriminant = b * b - 4 * a * c;
            if (discriminant > 0)
            {
                double root1 = (-b + Math.sqrt(discriminant)) / (2 * a);
                double root2 = (-b - Math.sqrt(discriminant)) / (2 * a);
                System.out.println("方程有两个不同实数解：x1 = " + root1 + ", x2 = " + root2);
            } else if (discriminant == 0)
            {
                double root = -b / (2 * a);
                System.out.println("方程有一个实数解：x = " + root);
            }
            else
            {
                double realPart = -b / (2 * a);
                double imaginaryPart = Math.sqrt(-discriminant) / (2 * a);
                System.out.println("方程有两个共轭复数解：");
                System.out.println("x1 = " + realPart + " + " + imaginaryPart + "i");
                System.out.println("x2 = " + realPart + " - " + imaginaryPart + "i");
            }
        }
    }
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入系数 a:");
        double a = scanner.nextDouble();
        System.out.println("请输入系数 b:");
        double b = scanner.nextDouble();
        System.out.println("请输入系数 c:");
        double c = scanner.nextDouble();

        QuadraticEquationSolver solver = new QuadraticEquationSolver(a, b, c);
        solver.solve();

        scanner.close();
    }
}